<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en-US">
<head>
<!-- GenHTML revision 25226-->
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Main Interface - The Java EE 6 Tutorial</title>
<meta name="robots" content="index,follow">
<meta name="robots" content="index,follow">
<meta name="date" content="2011-03-01">
<link rel="stylesheet" type="text/css" href="css/default.css">
<link rel="stylesheet" type="text/css" href="css/ipg.css">
<link rel="stylesheet" type="text/css" href="css/javaeetutorial.css">
</head>

<body>

<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tbody>
   <tr valign="top">
      <td width="400px"><p class="toc level1"><a href="docinfo.html">Document Information</a></p>
<p class="toc level1 tocsp"><a href="gexaf.html">Preface</a></p>
<p class="toc level1 tocsp"><a href="gfirp.html">Part&nbsp;I&nbsp;Introduction</a></p>
<p class="toc level2"><a href="bnaaw.html">1.&nbsp;&nbsp;Overview</a></p>
<p class="toc level2"><a href="gfiud.html">2.&nbsp;&nbsp;Using the Tutorial Examples</a></p>
<p class="toc level1 tocsp"><a href="bnadp.html">Part&nbsp;II&nbsp;The Web Tier</a></p>
<p class="toc level2"><a href="bnadr.html">3.&nbsp;&nbsp;Getting Started with Web Applications</a></p>
<p class="toc level2"><a href="bnaph.html">4.&nbsp;&nbsp;JavaServer Faces Technology</a></p>
<p class="toc level2"><a href="giepx.html">5.&nbsp;&nbsp;Introduction to Facelets</a></p>
<p class="toc level2"><a href="gjddd.html">6.&nbsp;&nbsp;Expression Language</a></p>
<p class="toc level2"><a href="bnaqz.html">7.&nbsp;&nbsp;Using JavaServer Faces Technology in Web Pages</a></p>
<p class="toc level2"><a href="gjcut.html">8.&nbsp;&nbsp;Using Converters, Listeners, and Validators</a></p>
<p class="toc level2"><a href="bnatx.html">9.&nbsp;&nbsp;Developing with JavaServer Faces Technology</a></p>
<p class="toc level2"><a href="gkmaa.html">10.&nbsp;&nbsp;JavaServer Faces Technology Advanced Concepts</a></p>
<p class="toc level2"><a href="bnawo.html">11.&nbsp;&nbsp;Configuring JavaServer Faces Applications</a></p>
<p class="toc level2"><a href="gkiow.html">12.&nbsp;&nbsp;Using Ajax with JavaServer Faces Technology</a></p>
<p class="toc level2"><a href="gkhxa.html">13.&nbsp;&nbsp;Advanced Composite Components</a></p>
<p class="toc level2"><a href="bnavg.html">14.&nbsp;&nbsp;Creating Custom UI Components</a></p>
<p class="toc level2"><a href="bnafd.html">15.&nbsp;&nbsp;Java Servlet Technology</a></p>
<p class="toc level2"><a href="bnaxu.html">16.&nbsp;&nbsp;Internationalizing and Localizing Web Applications</a></p>
<p class="toc level1 tocsp"><a href="bnayk.html">Part&nbsp;III&nbsp;Web Services</a></p>
<p class="toc level2"><a href="gijti.html">17.&nbsp;&nbsp;Introduction to Web Services</a></p>
<p class="toc level2"><a href="bnayl.html">18.&nbsp;&nbsp;Building Web Services with JAX-WS</a></p>
<p class="toc level2"><a href="giepu.html">19.&nbsp;&nbsp;Building RESTful Web Services with JAX-RS</a></p>
<p class="toc level2"><a href="gjjxe.html">20.&nbsp;&nbsp;Advanced JAX-RS Features</a></p>
<p class="toc level2"><a href="gkojl.html">21.&nbsp;&nbsp;Running the Advanced JAX-RS Example Application</a></p>
<p class="toc level1 tocsp"><a href="bnblr.html">Part&nbsp;IV&nbsp;Enterprise Beans</a></p>
<p class="toc level2"><a href="gijsz.html">22.&nbsp;&nbsp;Enterprise Beans</a></p>
<p class="toc level2"><a href="gijre.html">23.&nbsp;&nbsp;Getting Started with Enterprise Beans</a></p>
<p class="toc level2"><a href="gijrb.html">24.&nbsp;&nbsp;Running the Enterprise Bean Examples</a></p>
<p class="toc level2"><a href="bnbpk.html">25.&nbsp;&nbsp;A Message-Driven Bean Example</a></p>
<p class="toc level2"><a href="gkcqz.html">26.&nbsp;&nbsp;Using the Embedded Enterprise Bean Container</a></p>
<p class="toc level2"><a href="gkidz.html">27.&nbsp;&nbsp;Using Asynchronous Method Invocation in Session Beans</a></p>
<p class="toc level1 tocsp"><a href="gjbnr.html">Part&nbsp;V&nbsp;Contexts and Dependency Injection for the Java EE Platform</a></p>
<p class="toc level2"><a href="giwhb.html">28.&nbsp;&nbsp;Introduction to Contexts and Dependency Injection for the Java EE Platform</a></p>
<p class="toc level2"><a href="gjbls.html">29.&nbsp;&nbsp;Running the Basic Contexts and Dependency Injection Examples</a></p>
<p class="toc level2"><a href="gjehi.html">30.&nbsp;&nbsp;Contexts and Dependency Injection for the Java EE Platform: Advanced Topics</a></p>
<p class="toc level2"><a href="gkhre.html">31.&nbsp;&nbsp;Running the Advanced Contexts and Dependency Injection Examples</a></p>
<p class="toc level1 tocsp"><a href="bnbpy.html">Part&nbsp;VI&nbsp;Persistence</a></p>
<p class="toc level2"><a href="bnbpz.html">32.&nbsp;&nbsp;Introduction to the Java Persistence API</a></p>
<p class="toc level2"><a href="gijst.html">33.&nbsp;&nbsp;Running the Persistence Examples</a></p>
<p class="toc level2"><a href="bnbtg.html">34.&nbsp;&nbsp;The Java Persistence Query Language</a></p>
<p class="toc level2"><a href="gjitv.html">35.&nbsp;&nbsp;Using the Criteria API to Create Queries</a></p>
<p class="toc level2"><a href="gkjiq.html">36.&nbsp;&nbsp;Creating and Using String-Based Criteria Queries</a></p>
<p class="toc level2"><a href="gkjjf.html">37.&nbsp;&nbsp;Controlling Concurrent Access to Entity Data with Locking</a></p>
<p class="toc level2"><a href="gkjia.html">38.&nbsp;&nbsp;Improving the Performance of Java Persistence API Applications By Setting a Second-Level Cache</a></p>
<p class="toc level1 tocsp"><a href="gijrp.html">Part&nbsp;VII&nbsp;Security</a></p>
<p class="toc level2"><a href="bnbwj.html">39.&nbsp;&nbsp;Introduction to Security in the Java EE Platform</a></p>
<p class="toc level2"><a href="bncas.html">40.&nbsp;&nbsp;Getting Started Securing Web Applications</a></p>
<p class="toc level2"><a href="bnbyk.html">41.&nbsp;&nbsp;Getting Started Securing Enterprise Applications</a></p>
<p class="toc level1 tocsp"><a href="gijue.html">Part&nbsp;VIII&nbsp;Java EE Supporting Technologies</a></p>
<p class="toc level2"><a href="gijto.html">42.&nbsp;&nbsp;Introduction to Java EE Supporting Technologies</a></p>
<p class="toc level2"><a href="bncih.html">43.&nbsp;&nbsp;Transactions</a></p>
<p class="toc level2"><a href="bncjh.html">44.&nbsp;&nbsp;Resource Connections</a></p>
<p class="toc level2"><a href="bncdq.html">45.&nbsp;&nbsp;Java Message Service Concepts</a></p>
<p class="toc level2"><a href="bncgv.html">46.&nbsp;&nbsp;Java Message Service Examples</a></p>
<p class="toc level2"><a href="gkahp.html">47.&nbsp;&nbsp;Advanced Bean Validation Concepts and Examples</a></p>
<p class="toc level2"><a href="gkeed.html">48.&nbsp;&nbsp;Using Java EE Interceptors</a></p>
<p class="toc level1 tocsp"><a href="gkgjw.html">Part&nbsp;IX&nbsp;Case Studies</a></p>
<p class="toc level2"><a href="gkaee.html">49.&nbsp;&nbsp;Duke's Tutoring Case Study Example</a></p>
<p class="toc level3"><a href="gkaei.html">Design and Architecture of Duke's Tutoring</a></p>
<div id="scrolltoc" class="onpage">
<p class="toc level3"><a href="">Main Interface</a></p>
<p class="toc level4"><a href="#gkafj">Java Persistence API Entities Used in the Main Interface</a></p>
<p class="toc level4"><a href="#gkafc">Enterprise Beans Used in the Main Interface</a></p>
<p class="toc level4"><a href="#gkaet">Facelets Files Used in the Main Interface</a></p>
<p class="toc level4"><a href="#gkadh">Helper Classes Used in the Main Interface</a></p>
<p class="toc level4"><a href="#gkada">Properties Files</a></p>
<p class="toc level4"><a href="#gkaev">Deployment Descriptors Used in Duke's Tutoring</a></p>
</div>
<p class="toc level3 tocsp"><a href="gkafw.html">Administration Interface</a></p>
<p class="toc level4"><a href="gkafw.html#gkaen">Enterprise Beans Used in the Administration Interface</a></p>
<p class="toc level4"><a href="gkafw.html#gkacb">Facelets Files Used in the Administration Interface</a></p>
<p class="toc level3 tocsp"><a href="gkjnn.html">Running the Duke's Tutoring Case Study Application</a></p>
<p class="toc level4"><a href="gkjnn.html#gkjol">Setting Up GlassFish Server</a></p>
<p class="toc level5"><a href="gkjnn.html#gkjod">Adding a User to the File Realm in GlassFish Server</a></p>
<p class="toc level4 tocsp"><a href="gkjnn.html#gkjoa">Running Duke's Tutoring</a></p>
<p class="toc level5"><a href="gkjnn.html#gkjnr">To Build and Deploy Duke's Tutoring in NetBeans IDE</a></p>
<p class="toc level5"><a href="gkjnn.html#gkjog">To Build and Deploy Duke's Tutoring Using Ant</a></p>
<p class="toc level5"><a href="gkjnn.html#gkjoc">Using Duke's Tutoring</a></p>
<p class="toc level1 tocsp"><a href="idx-1.html">Index</a></p>
</td>
      <td width="10px">&nbsp;</td>
      <td>
         <div class="header">
             <div class="banner">
                <table width="100%" border="0" cellpadding="5" cellspacing="0">
                   <tbody>
                      <tr>
                         <td valign="bottom"><p class="Banner">The Java EE 6 Tutorial
</p></td>
                         <td align="right"  valign="bottom"><img src="graphics/javalogo.png" alt="Java Coffee Cup logo"></td>
                      </tr>
                   </tbody>
                </table>
             </div>

             <div class="header-links">
	         <a href="./index.html">Home</a> | 
<a href="../information/download.html">Download</a> | 
<a href="./javaeetutorial6.pdf">PDF</a> | 
<a href="../information/faq.html">FAQ</a> | 
<a href="http://download.oracle.com/javaee/feedback.htm">Feedback</a>

             </div>
             <div class="navigation">
                 <a href="gkaei.html"><img src="graphics/leftButton.gif" border="0" alt="Previous" title="Previous"></a>
                 <a href="p1.html"><img src="graphics/upButton.gif" border="0" alt="Contents" title="Contents"></a>
                 <a href="gkafw.html"><img src="graphics/rightButton.gif" border="0" alt="Next" title="Next"></a>
             </div>
         </div>

	 <div class="maincontent">      	 
             

<a name="gkafh"></a><h2>Main Interface</h2>
<p>The main interface allows students and staff to check students in and out,
and record when students are outside at the playground.</p>



<a name="gkafj"></a><h3>Java Persistence API Entities Used in the Main Interface</h3>
<p>The entities used in the main interface encapsulate data stored and manipulated by
Duke's Tutoring, and are located in the <tt>dukestutoring.entity</tt> package.</p>

<p>The <tt>Person</tt> entity defines attributes common to students and guardians tracked by the
Duke's Tutoring application. These attributes are the person's name and contact information, including
phone numbers and email address. The phone number and email address attributes have
Bean Validation annotations to ensure that the submitted data is well-formed. The email
attribute uses a custom validation class, <tt>dukestutoring.util.Email</tt>. <tt>Person</tt> has two subclasses, <tt>Student</tt> and
<tt>Guardian</tt>. For additional data common to all people, the <tt>PersonDetails</tt> entity is
used to store attributes like pictures and the person's birthday that aren't included
in the <tt>Person</tt> entity for performance reasons.</p>

<p>The <tt>Student</tt> entity stores attributes specific to the students that come to tutoring.
This includes information like the student's grade level and school. The <tt>Guardian</tt> entity's attributes
are specific to the parents or guardians of a <tt>Student</tt>. Students and guardians
have a many-to-many relationship. That is, a student may have a one or
more guardians, and a guardian may have one or more students. </p>

<p>The <tt>Address</tt> entity represents a mailing address, and is associated with <tt>Person</tt> entities.
Addresses and people have a many-to-one relationship. That is, one person may have
many addresses.</p>

<p>The <tt>TutoringSession</tt> entity represents a particular day at the tutoring center. A particular
tutoring session tracks which students attended that day, and which students went to
the park. Associated with <tt>TutoringSession</tt> is the <tt>StatusEntry</tt> entity, which logs when a
student's status changes. Student's status changes when they check in to a tutoring
session, when they go to the park, and when they check out. The
status entry allows the tutoring center staff to track exactly which students attended
a tutoring session, when they checked in and out, which students went to
the park while they were at the tutoring center, and when they went
to and came back from the park.</p>

<p>For information on creating Java Persistence API entities, see <a href="bnbpz.html">Chapter&nbsp;32, Introduction to the Java Persistence API</a>. For information on
validating entity data, see<a href="bnbqa.html#gkahq">Validating Persistent Fields and Properties</a> and <a href="gkahp.html">Chapter&nbsp;47, Advanced Bean Validation Concepts and Examples</a>.</p>



<a name="gkafc"></a><h3>Enterprise Beans Used in the Main Interface</h3>
<p>The enterprise beans used in the main interface provide the business logic for
Duke's Tutoring, and are located in the <tt>dukestutoring.ejb</tt> package.</p>

<p><tt>ConfigBean</tt> is singleton session bean used to create the default students when the
application is initially deployed, and to create an automatic EJB timer that creates
tutoring session entities every weekday.</p>

<p><tt>RequestBean</tt> is a stateless session bean containing the business methods for the main
interface. Students or staff can check students in and out and track when
they go to and come back from the park. The bean also has
business methods for retrieving lists of students. The business methods in <tt>RequestBean</tt> use
strongly-typed Criteria API queries to retrieve data from the database.</p>

<p>For information on creating and using enterprise beans, see <a href="bnblr.html">Part&nbsp;IV, Enterprise Beans</a>. For information
on creating strongly-typed Criteria API queries, see <a href="gjitv.html">Chapter&nbsp;35, Using the Criteria API to Create Queries</a>.</p>



<a name="gkaet"></a><h3>Facelets Files Used in the Main Interface</h3>
<p>The Duke's Tutoring application uses Facelets to display the user interface, and makes
extensive use of the templating features of Facelets. Facelets is the default display
technology for JavaServer Faces, and consists of XHTML files located in the <tt></tt><i>tut-install</i><tt>/examples/case-studies/dukes-tutoring/web</tt>
directory.</p>

<p>The following Facelets files are used in the main interface:</p>

<dl><dt><tt>template.xhtml</tt></dt>
<dd><p>Template file for the main interface.</p>

</dd>
<dt><tt>error.xhtml</tt></dt>
<dd><p>Error file if something goes wrong (this shouldn't occur).</p>

</dd>
<dt><tt>index.xhtml</tt></dt>
<dd><p>Landing page for the main interface.</p>

</dd>
<dt><tt>park.xhtml</tt></dt>
<dd><p>Page showing who is currently at the park.</p>

</dd>
<dt><tt>current.xhtml</tt></dt>
<dd><p>Page showing who is currently in today's tutoring session.</p>

</dd>
<dt><tt>statusEntries.xhtml</tt></dt>
<dd><p>Page showing the detailed status entry log for today's session.</p>

</dd>
<dt><tt>resources/components/allStudentsTable.xhtml</tt></dt>
<dd><p>A composite component for a table displaying all active students.</p>

</dd>
<dt><tt>resources/components/currentSessionTable.xhtml</tt></dt>
<dd><p>A composite component for a table displaying all students in today's session.</p>

</dd>
<dt><tt>resources/components/parkTable.xhtml</tt></dt>
<dd><p>A composite component for a table displaying all students currently at the park.</p>

</dd>
<dt><tt>WEB-INF/includes/navigation.xhtml</tt></dt>
<dd><p>XHTML fragment for the main interface's navigation bar.</p>

</dd>
<dt><tt>WEB-INF/includes/footer.xhtml</tt></dt>
<dd><p>XHTML fragment for the main interface's footer.</p>

</dd>
</dl>
<p>For information on using Facelets, see <a href="giepx.html">Chapter&nbsp;5, Introduction to Facelets</a>.</p>



<a name="gkadh"></a><h3>Helper Classes Used in the Main Interface</h3>
<p>The following helper classes, in the <tt>dukestutoring.util</tt> package, are used in the main
interface:</p>

<dl><dt><tt>CalendarUtil</tt></dt>
<dd><p>A class that provides a method to strip the unnecessary time data from <tt>java.util.Calendar</tt> instances.</p>

</dd>
<dt><tt>Email</tt></dt>
<dd><p>Custom Bean Validation annotation class for validating email addresses in the <tt>Person</tt> entity.</p>

</dd>
<dt><tt>StatusType</tt></dt>
<dd><p>An enumerated type defining the different statuses that a student can have. Possible statuses are: <tt>IN</tt>, <tt>OUT</tt>, and <tt>PARK</tt>. <tt>StatusType</tt> is used throughout the application, including in the <tt>StatusEntry</tt> entity, and throughout the main interface. <tt>StatusType</tt> also defines a <tt>toString</tt> method that returns a localized translation of the status based on the locale.</p>

</dd>
</dl>


<a name="gkada"></a><h3>Properties Files</h3>
<p>The strings used in the main interface are encapsulated into resource bundles to
allow the display of localized strings in multiple locales. Each of the following
properties files has locale-specific files, appended with the locale code, containing the translated
strings for that locale. For example, <tt>Messages_es.properties</tt> contains the localized strings for
Spanish locales.</p>

<dl><dt><tt>ValidationMessages.properties</tt></dt>
<dd><p>Strings for the default locale used by the Bean Validation runtime to display validation messages. This file must be named <tt>ValidationMessages.properties</tt> and located in the default package as required by the Bean Validation specification.</p>

</dd>
<dt><tt>dukestutoring/web/messages/Messages.properties</tt></dt>
<dd><p>Strings for the default locale for the main and administration Facelets interface.</p>

</dd>
</dl>
<p>For information on localizing web applications, see <a href="bnaxc.html">Registering Custom Localized Static Text</a> and <a href="bnaxb.html">Registering Custom Error Messages</a>.</p>



<a name="gkaev"></a><h3>Deployment Descriptors Used in Duke's Tutoring</h3>
<p>The following deployment descriptors are used in Duke's Tutoring:</p>

<dl><dt><tt>src/conf/beans.xml</tt></dt>
<dd><p>An empty deployment descriptor file used to enable the CDI runtime.</p>

</dd>
<dt><tt>web/WEB-INF/faces-config.xml</tt></dt>
<dd><p>The JavaServer Faces configuration file.</p>

</dd>
<dt><tt>src/conf/persistence.xml</tt></dt>
<dd><p>The Java Persistence API configuration file.</p>

</dd>
<dt><tt>web/WEB-INF/glassfish-web.xml</tt></dt>
<dd><p>The GlassFish-specific configuration file.</p>

</dd>
<dt><tt>web/WEB-INF/web.xml</tt></dt>
<dd><p>The web application configuration file.</p>

</dd>
</dl>
<p>No enterprise bean deployment descriptor is used in Duke's Tutoring. Annotations in the
enterprise bean class files are used for the configuration of enterprise beans in
this application.</p>


         </div>
         <div class="navigation">
             <a href="gkaei.html"><img src="graphics/leftButton.gif" border="0" alt="Previous" title="Previous"></a>
             <a href="p1.html"><img src="graphics/upButton.gif" border="0" alt="Contents" title="Contents"></a>
             <a href="gkafw.html"><img src="graphics/rightButton.gif" border="0" alt="Next" title="Next"></a>
         </div>

         <div class="copyright">
      	    <p>Copyright &copy; 2011, Oracle and/or its affiliates. All rights reserved. <a href="docinfo.html">Legal Notices</a></p>
      	 </div>

      </td>
   </tr>
</tbody>
</table>
</body>
</html>

